using System;
using System.Linq;
using FoundationLib.Ifc.Data;

namespace FoundationLib.Ifc.Logging 
{
	/// <summary>
	/// This class represents a special kind of business logger, persisting all log
	/// information in a database.
	/// </summary>
	[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
	public abstract class DbBusinessLogger : BusinessLogger 
	{
		/// <summary>
		/// The data access object to be used to persist log information
		/// </summary>
		private IDataAccessObject dataAccessObject;


		/// <summary>
		/// Creates a new database business logger.
		/// </summary>
		protected DbBusinessLogger(): base()
		{
		}

		/// <summary>
		/// Creates a new database business logger.
		/// </summary>
		/// <param name="dao">The data access object to be used for persisting log
		/// information</param>
		/// <exception cref="ArgumentNullException">Data access object is not defined.</exception>
		protected DbBusinessLogger(IDataAccessObject dao): this()
		{
			if (dao == null)
				throw new ArgumentNullException("dao");

			this.dataAccessObject = dao;
		}

		/// <summary>
		/// Gets the data access object to be used for logging.
		/// </summary>
		public virtual IDataAccessObject DataAccessObject
		{
			get
			{
				return this.dataAccessObject;
			}
		}

	}

}